<html>
 <head>
  <title>YouTube Duplicate Video Finder - Search Page</title>
  <style type="text/css">
  	fieldset { font-family: Arial; margin: 25 auto; text-align: center; width: 550px; border-style: solid; border-color: black; padding: 10px }
	legend { font-size: 25px; font-weight: bold; font-variant: small-caps }
	.buttons { border-style: solid; border-color: #666666; background-color: #EEEEEE; margin-top: 3px; margin-bottom: 2px }
	.texts { border-style: solid; border-color: #666666; background-color: #EEEEEE; padding-left: 2px; padding-right: 2px; margin-top: 3px; margin-bottom: 2px }
	#tolerance { border-style: solid; border-color: #666666; background-color: #EEEEEE; padding-left: 2px; padding-right: 2px }
	#errorDiv { border-style: solid; border-color: red; margin-left: 5px; margin-right: 5px; margin-top: 15px }
  	#tube { color: white; background-color: red; padding-left: 3px; padding-right: 3px }
  	.defaultDiv { margin-bottom: 5px; margin-top: 5px }
  </style>
  <script src="../../prototypeServer/" type="text/javascript"></script>
  <script language="javascript" type="text/javascript">
    function getDownloadCount()
	{
		new Ajax.PeriodicalUpdater('downloadText', '../functionServer', {
		  method: 'get',
		  frequency: 3,
		  onSuccess: videoDownloaded,
		  parameters: { 'function': 'getDownloadCount' }
		});
    }

    function getCompareCount()
	{
		new Ajax.PeriodicalUpdater('compareText', '../../resultsServer/functionServer', {
		  method: 'get',
		  frequency: 3,
		  parameters: { 'function': 'getCompareCount' }
		});
    }

    function videoDownloaded(response)
    {
		if (response.responseText == 'All videos downloaded.') {
			moveNext();
		}
	}

	function moveNext()
	{
		new Ajax.Request('../functionServer',{
	      method: 'get',
	      parameters: { 'function': 'moveNext' },
	      onComplete: moveNextComplete
	    });
	}

	function moveNextComplete()
	{
		window.location = '../../resultsServer/pageServer/';
	}

	function randomString() {
		var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
		var string_length = 8;
		var randomstring = '';
		for (var i=0; i<string_length; i++) {
			var rnum = Math.floor(Math.random() * chars.length);
			randomstring += chars.substring(rnum,rnum+1);
		}
		return randomstring;
	}

	function getTimeId() {
		return new Date().getTime();
	}
  </script>
 </head>
 <body onLoad='getDownloadCount(); getCompareCount();'>
  <fieldset>
   <legend>You<span id="tube">Tube</span> Duplicate Video Finder</legend>
	<div id="downloadText" class="defaultDiv">
	</div>
	<div id="compareText" class="defaultDiv">
	</div>
	<div>
	  <input type="button" name="mainContinueButton" id="mainContinueButton" class="buttons" value="Stop & Show Results" onClick='moveNext();'>
	</div>
  </fieldset>
 </body>
</html>